Database applications interact with a database server by submitting to the database server commands that cause the database server to perform operations on data stored in a database. A database command that is sent from a database application to a database server contains the “original statement” of the database command.
For the database server to process the commands, the commands must conform to a database language supported by the database server. One database language supported by many database servers is known as the Structured Query Language (SQL).
When a database server receives the original statement of a database command from a database application, the database server must first determine which actions should be performed in response to the database command, and then perform those actions. The act of preparing for performance of those actions is generally referred to as “compiling” the database command, while performing those actions is generally referred to as “executing” the database command.
Various database languages, such as SQL, support special-purpose constructs referred to herein as “cursors”. During the compilation of a query statement, the database server may perform a significant amount of preliminary work for the statement, such as parsing, semantic analysis, and query plan generation. A cursor stores the results of much of this preliminary work. For example, one set of information stored in a cursor includes the execution plan for performing the operations specified by the SQL statement.
One method of representing an execution plan is a row-source tree. At execution, traversal of a row-source tree from the bottom up yields a sequence of steps for performing the operation(s) specified by the SQL statement. A row-source tree is composed of row-sources. During the compilation process, row-sources are allocated, and each row-source is linked to zero, one, two, or more underlying row-sources. The makeup of a row-source tree depends on the query and the decisions made by a query optimizer during the compilation process. Typically, a row-source tree is comprised of multiple levels. The lowest level, the leaf nodes, access rows from a database or other data store. The top row-source, the root of the tree, produces, by composition, the rows of the query that the tree implements. The intermediate levels perform various transformations on rows produced by underlying row-sources.
The row-source tree representation of execution plans is described in detail in U.S. Pat. No. 5,857,180, entitled “Method and apparatus for implementing parallel operations in a database management system”, issued to Hallmark et al on Jan. 5, 1999, the entire contents of which are incorporated herein. Hallmark also describes a “row-source approach” for parallelizing the operations required by an SQL command by parallelizing portions of the execution plan of the query. The row-source approach to parallelizing queries is described in greater detail below.